﻿/*
 * Created by SharpDevelop.
 * User: it1050
 * Date: 20/08/10
 * Time: 23.31
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Drawing;
using System.Windows.Forms;

namespace PN
{
	/// <summary> Description of f_dbChartAccounts. </summary>
	public partial class frmdbChartAccounts : Form
	{
		public frmdbChartAccounts()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
		}
		
		void fRunSearch()
		{ //impostro la stringa per la qry da passare alla SearchForm, 
			//apro la SearchForm e recupero i dati dal DB

			string lvSQLString = "SELECT pdc_id as ID, pdc_cod as Code, pdc_des as Description FROM db_pdc";
			lvSQLString=lvSQLString + " WHERE PDC_COD LIKE \"%" + edtCode.Text.Trim() + "%\"";
			lvSQLString=lvSQLString + " AND PDC_DES LIKE \"%" + edtDes.Text.Trim() + "%\"";
			
			frmSearch lFrm = new frmSearch();
			lFrm.SetSQLString=lvSQLString;
			//imposto la SQLstring
			lFrm.ShowDialog();

			//recupero tutte info dalla tabella del DB basandomi sull'ID recuperata
			lvSQLString = "SELECT * from DB_PDC where PDC_ID =" + lFrm.GetIDResult;
			
			
			//imposto il testo della status label
			sBarLabel.Text="Editing";
					
		}  //fRunSearch
		
		
		void FrmdbChartAccountsKeyDown(object sender, KeyEventArgs e)
		{//controllo la selezione dei tasti funzione per attivare le special func
			
			switch (e.KeyCode) 
			{
				case Keys.Return : //apro la mask di ricerca se sono in modalita search 
					if ( sBarLabel.Text == "Search Mode") 
						fRunSearch();
					break;
				case Keys.F3 : //imposto la modalità search Mode
				  sBarLabel.Text="Search Mode";
				  edtCode.Focus();
					break;
			}; //switch //e.keycode
			
		}  //FrmdbChartAccountsKeyDown
	}
}	//namespace PN
